const app = getApp();
Page({
  data: {
    userInfo_role: wx.getStorageSync('userInfo_role'),//app.globalData.userInfo_role,
    // 学生基本信息
    name: '张小萌',
    gender: '女',
    age: 12,
    avatarUrl: '',
    school: '阳光实验小学',
    parentName: '张明',
    phone: '138****5678',

    // 学习信息
    level: 'intermediate', // primary, intermediate, advanced
    levelText: '中级',
    attendedHours: 36,
    remainingHours: 24,

    employeeId: 'CG2023001',
    department: '课程咨询部',
    position: '高级课程顾问',
    email: 'zhang.guwen@edu.com',

    // 统计数据
    studentCount: 45,
    courseCount: 12,
    monthlyPerformance: '¥128,600',
    completionRate: 85,
    newStudents: 8,
    choosePop: false,
    roleList: [
      { value: 'student', label: '学生' },
      { value: 'teacher', label: '老师' },
      { value: 'counselor', label: '顾问' },
    ]


  },

  onLoad: function () {
    // 页面加载时，可以请求服务器数据更新学生信息
    // this.loadStudentInfo();
  },

  // 查看签到记录
  viewAttendance: function () {
    wx.navigateTo({
      url: '/pages/course-records/index'
    });
  },

  // 加载学生信息
  loadStudentInfo: function () {
    // 实际开发中这里应该是从服务器获取数据
    // wx.request({
    //   url: 'https://your-api.com/student/profile',
    //   success: (res) => {
    //     this.setData({
    //       ...res.data
    //     });
    //   }
    // });
  },
  navigateToStudentList() {
    wx.navigateTo({
      url: '/pages/myStudent/index'
    });
  },
  // 切换角色
  change() {
    this.setData({
      choosePop: true
    })
  },
  chooseRole(e) {
    const value = e.currentTarget.dataset.value;
    wx.setStorageSync('userInfo_role',value)
    this.setData({
      choosePop: false,
      userInfo_role: value
    })
  }
});